package vip.liux.front.application.listeners;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.PayloadApplicationEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import vip.liux.front.application.listeners.events.AsyncEvent;

/**
 * 事件监听总线
 */
@Component
public class ApplicationEventListenerBus {

    private static final Logger log = LoggerFactory.getLogger(ApplicationEventListenerBus.class);

    @EventListener
    public void handleEvent(PayloadApplicationEvent<String> event) {
        log.info("Received event: {}", event.getPayload());
    }

    @Async
    @EventListener
    public void handleEvent(AsyncEvent event) {
        log.info("Received async event: {}", event.getMessage());
    }
}
